package dp;

import java.util.ArrayList;
import java.util.List;

public class FindGoodDaysToRobTheBank2100 {
    public List<Integer> goodDaysToRobBank(int[] security, int time) {
        int length = security.length;
        int[] forward = new int[length];
        int[] backward = new int[length];
        forward[0] = 0;
        backward[length-1] = 0;
        for (int i = 1; i < length; i++) {
            if(security[i-1]>=security[i]){
                forward[i]=forward[i-1]+1;
            }else {
                forward[i] = 0;
            }

            if(security[length-i]>=security[length-1-i]){
                backward[length-1-i]=backward[length-i]+1;
            }else {
                backward[length-1-i] = 0;
            }
        }
        List<Integer> result = new ArrayList<>();
        for (int i = 0; i < length; i++) {
            if(forward[i]>=time&&backward[i]>=time){
                result.add(i);
            }
        }
        return result;


    }
}
